package com.tb.dubbo_service;

import com.github.pagehelper.PageHelper;
import com.tb.dubbo.IGoodsCommentsService;
import com.tb.mapper.GoodsMapper;
import com.tb.pojo.Goods;
import com.tb.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GoodsCommentsServiceImpl implements IGoodsCommentsService {

    @Autowired
    private GoodsMapper goodsMapper;

    public Map<String, Object> goodsComments(Map<String, Object> map) {
        try {
            long count = goodsMapper.goodsComments(map).getListComments().size();
            PageHelper.startPage((Integer) map.get("page"), (Integer) map.get("rows"));
            Goods goods = goodsMapper.goodsComments(map);

            Map<String, Object> rmap = new HashMap<>();
            rmap.put("count", count);
            rmap.put("goods", goods);
            return rmap;
        } catch (Exception e) {
            return null;
        }
    }
}
